'use strict';

const BaseService = require('./base');
const {
  CommonDeletedEnum
} = require("../utils/enum");
const {
  listToTree
} = require("../utils");
class SystemMenuService extends BaseService {
  constructor(ctx) {
    super(ctx, 'SystemMenu');
  }
  async getSuperAdminMenuTree() {
    // 查找所有的权限菜单，组装成树结构，单独拆分组成树的方法
    const menuList = await this.ctx.model.SystemMenu.findAll({
      where: {
        deleted: CommonDeletedEnum.NOT_DELETED
      },
      raw: true
    })
    return listToTree(menuList).sort((a, b) => a.sort - b.sort)
  }
}

module.exports = SystemMenuService;
